
Component({
  // 组件的属性列表
  properties: {
    // 接受父组件的给的数据
    active: {
        type: "String",
        value: ""
    }
  },
  data: { 
    selected: undefined,
    color: "#333333",  //默认文字颜色
    selectedColor: "#e6a511",  //选中文字颜色
    "list": [
      {
          "pagePath": "../../pages/page1/page1",
          "text": "白手",
          "iconPath": "../../images/白手1.png",
          "selectedIconPath": "../../images/白手2.png"
      },
      {
          "pagePath": "../../pages/page3/page3",
          "text": "出售",
          "iconPath": "../../images/出售.png",
          "selectedIconPath": "../../images/出售.png"
      },
      {
        "pagePath": "../../pages/pleasebuy/pleasebuy",
        "text": "求购",
        "iconPath": "../../images/求购.png",
        "selectedIconPath": "../../images/求购.png"
      },
      {
        "pagePath": "../../pages/mine/mine",
        "text": "我的",
        "iconPath": "../../images/我的.png",
        "selectedIconPath": "../../images/我的.png"
      }
  ]
  },
  attached() {
    
  },
  methods: {
    switchTab(e) {
      if (this.data.selected === e.currentTarget.dataset.index) {
        return false;
      } else {
        const url=e.currentTarget.dataset.path
        wx.navigateTo({url})
      }
    },
    run() {
      console.log(this.data.active);      
      this.setData({
          // 通过this.data获取父组件里传过来的值
          selected: this.data.active
      });
      console.log(this.data.selected);
    }
  }
})